﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;


public class Stock
{
    public string Name;
    public double Price;
}


/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 

[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{

    private static readonly Random random = new Random();

    public WebService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public List<Stock> displayStock()
    {
        double price = 0;
        //Random random = new Random(50);
        price = random.NextDouble();
        Stock stock = new Stock();
        stock.Name = "MSFT";
        stock.Price = Math.Round(price, 2);

        List<Stock> stockList = new List<Stock>();
        stockList.Add(stock);

        price = random.NextDouble();
        stock = new Stock();
        stock.Name = "APPL";
        stock.Price = Math.Round(price, 2);
        stockList.Add(stock);

        price = random.NextDouble();
        stock = new Stock();
        stock.Name = "GOOG";
        stock.Price = Math.Round(price, 2);
        stockList.Add(stock);

        return stockList;
    }

}
